<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="Clases.*" %>
<%@ page import="Datos.ProfesionalAdapter" %>
<%@ page import="java.util.ArrayList" %>
<%if (session.getAttribute("UsuarioActual")!=null){ %> 
<%
ProfesionalAdapter adapter = new ProfesionalAdapter();
ArrayList<Profesional> profesionales = new ArrayList<Profesional>();
if(request.getParameter("txt") != null){profesionales = adapter.buscarPorProfesional(request.getParameter("txt"),Integer.parseInt(session.getAttribute("IdSecretaria").toString()));}
else{profesionales = adapter.getAllProfesionales(Integer.parseInt(session.getAttribute("IdSecretaria").toString()));}

if(profesionales != null){
%>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Profesionales</title>
<link rel="shortcut icon" href="images/favicon.ico" />
<link href="dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="css/listarstyle.css" rel="stylesheet" />
</head>

  <body>
<%@include file="menusecretarias.jsp" %>

  <div class="container">
	<div class="starter-template">
        <div class="main">
  			<div class="header_bg">
    			<div class="header">
      				
    			</div>
    			<div class="clr"></div>
  				</div>
        
    			<div class="clr"></div>
  				<div class="clr"></div>
  				<div class="body_resize">
    				<div class="body">
      					<div class="body_listar">
					        <h2>LISTADO DE PROFESIONALES</h2>
					        
					        <table align="center" width="900" border="0" cellspacing="1" cellpadding="3">
					          <tr>
					            <td height="40" colspan="2"><a href="registrarprofesional.jsp"><img src="images/add.png" width="16" height="16" align="left" style="margin: 4px 10px 0 0;" />Agregar un Profesional</a></td>
					            <td height="40" colspan="4"><div  align="right">
					            <form id="form1" name="form1" method="get" action="">
					              Buscar 
					              <input type="text" name="txt" id="txt" value="" />
					              <input type="submit" name="buscar" id="buscar" value="Buscar" />
					            </form></div></td>
					          </tr>
					          <tr><!-- generar dinámicamente -->
					            <td width="150" bgcolor="#CCCCCC">Nombre</td>
					            <td width="150" bgcolor="#CCCCCC">Apellido</td>
					            <td width="200" bgcolor="#CCCCCC">E-Mail</td>
					            <td width="100" bgcolor="#CCCCCC">Secretaria</td>
					            <td width="60" bgcolor="#CCCCCC"><strong>Editar</strong></td>
					            <td width="60" bgcolor="#CCCCCC"><strong>Eliminar</strong></td> 
					          </tr>
					          
					          <%for(Profesional prof:profesionales) {%>
					            <tr>
					              <td width="150" ><%=prof.getNombre()%></td>
					              <td width="150" ><%=prof.getApellido() %></td>
					              <td width="200" ><%=prof.getMail() %></td>
					              <td width="200" ><%=prof.getNomSecretaria() %></td>
					              <td width="60" ><a href="registrarprofesional.jsp?id=<%=prof.getId() %>">Editar</a></td>
								  <td width="60" ><a href="Final_IUDProfesional?TipoAccion=2&Id=<%=prof.getId() %>" onclick="return confirmar('¿Seguro que deseas eliminar el registro?')">Eliminar</a></td>
								</tr>
					          <%} %>
					          <tr>
					            <td colspan="7" align="right">
					            Cantidad de registros: <%=profesionales.size() %> 
					            </td>
					          </tr>
					        </table>
        <p>&nbsp;</p>
      </div>
      <div class="clr"></div>
    </div>
    <div class="clr"></div>
  </div>
</div>
        
      </div>

    </div>


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
    
    
    <!-- Alerta confirmar eliminación -->
    <script language="JavaScript"> 
	function confirmar ( mensaje ) { return confirm( mensaje ); } 
	</script>
  </body>
</html>
<%}%>
<%}else {response.sendRedirect("LoginProfesional.jsp");}%>
